<div class = "main-view">

    <div class="left-margin top-margin"><strong class="am-text-primary am-text-lg">推送信息</strong></div>

    <form class="am-form-inline left-margin top-margin" role="form">
        <div class="am-form-group">
            <label>推送信息方式：</label>
            <select data-am-selected="{btnSize: 'sm'}" ng-model="mode" style="margin-left: 0px;height: 30px">
                <!--<option value=0></option>-->
                <option value='1'>系统通知</option>
                <option value='2'>私信</option>
                <option value='3'>手机短消息</option>
            </select>
            <br><br>
            <label>推送用户类别：</label>
            <select data-am-selected="{btnSize: 'sm'}" ng-model="type" style="margin-left: 0px;height: 30px">
                <!--<option value=0></option>-->
                <option value='1'>雷锋团成员</option>
                <option value='2'>小区版主</option>
                <option value='13'>注册用户</option>
                <option value='3'>7天内新注册用户</option>
                <option value='4'>3天未上线用户</option>
                <option value='5'>7天未上线用户</option>
                <option value='6'>2周未上线用户</option>
                <option value='11'>大于4周未上线</option>
                <!--<option value='7'>导入用户</option>-->
                <!--<option value='8'>选择小区</option>-->
                <!--<option value='9'>省市用户</option>-->
                <option value='10'>特定用户</option>
            </select>

            <label ng-show="type==13" style="width:auto">开始时间：</label><input  ng-show="type==13" type="text" class="modal-input" data-date-format="yyyy-mm-dd hh:ii" ng-model="beginDate" id="beginDate">
            <label ng-show="type==13" style="width:auto">结束时间：</label><input  ng-show="type==13" type="text" class="modal-input" data-date-format="yyyy-mm-dd hh:ii" ng-model="endDate" id="endDate">
            <br><br>
            <div ng-show="mode==1">
                <label style="width: 115px">打开方式：</label>
                <select data-am-selected="{btnSize: 'sm'}" ng-model="openType" style="margin-left: 0px;height: 30px">
                    <option value=1>问答</option>
                    <option value=3>活动/H5</option>
                    <option value=4>专题</option>
                    <option value=12>商品详情页</option>
                    <option value=14>积分商城</option>
                    <option value=16>邀请有礼</option>
                </select>
            </div>
        </div>
        <!--</div>-->
    </form>

    <!--ng-show="mode==1"-->
    <!--<form class="am-form-inline left-margin top-margin" role="form">-->

    <div class="am-form-inline left-margin top-margin">
            <div ng-show="mode==1">
                <label style="width: 120px">推送内容：</label><input class="modal-input" style="width: 500px;height: 30px" ng-model="message">
                <label class="control-label"  style="width:180px;color:red">最多可推送22个字符</label>
            </div>
            <br>
            <div ng-show="(openType==3 || openType==4)  && mode==1">
                <label style="width: 120px">跳转页面：</label><input class="modal-input" style="width: 800px;height: 30px" ng-model="url" >
                <br>
            </div>

            <div ng-show="openType==1 && mode==1">
                <label style="width: 120px">问答ID：</label><input class="modal-input" style="width: 500px;height: 30px" ng-model="question" >
            </div>
            <!--<br><br>-->
            <div ng-show="type==10">
                <label class="control-label">推送用户：</label><br />
                <textarea style="width:600px;height:100px;" ng-model="sendNumber"></textarea>
            </div>
            <div ng-show="mode==2 ">
                <label class="control-label">私信内容：</label><br />
                <textarea style="width:600px;height:100px;" ng-model="letter"></textarea>
            </div>
            <!--<br><br>-->
            <div ng-show="mode==3">
                <label class="control-label">短信内容：</label><br />
                <textarea style="width:600px;height:100px;" ng-model="sms"></textarea>
            </div>
            <div ng-show="type==8">
                <label>选择小区:</label><br>
                <div class = "city-cascading" style = "display: inline-block;" id = "cascad-edit"></div>

                <input type="text" class="modal-input" ng-model="cname_edit" id = "cname_filter_edit" ng-change="cnameFilter(cname_edit,'edit')" placeholder="搜索小区" style = "width: 200px;">
                <table id="manyCommunity_edit" style="width:500px;" border="0" >
                    <tr align="center">
                        <td >
                            <select id="communities_select_edit" multiple="multiple" ng-model="oneCommunity_edit"
                                    style="width: 200px;height:200px;">
                                <option ng-repeat="community in communityList_edit" value="{{community.objId}}">{{community.communityName}}</option>
                            </select>
                        </td>
                        <td >
                            <input type="button" value=" >> " id="addAllCommunity_edit" ng-click="addAllCommunity('edit')" /><br/><br/>
                            <input type="button" value=" > " id="addCommunity_edit" ng-click="addCommunity('edit')" /><br /><br/>
                            <input type="button" value=" < " id="removeCommunity_edit" ng-click="removeCommunity('edit')"/><br/><br/>
                            <input type="button" value=" << " id="removeAllCommunity_edit" ng-click="removeAllCommunity('edit')"/>
                        </td>
                        <td>
                            <select id="selCommunitys_edit" multiple="multiple"
                                    style="width: 200px;height:200px;" ng-model="selCommunitys_edit">

                            </select>
                        </td>

                    </tr>
                </table>


            </div>
            <div ng-show="type==9">
                <label>选择省市:</label><br>
                <div class = "city-cascading" style = "display: inline-block;" id = "cascad-city"></div>
            </div>
    </div>

    <!--</form>-->
    <br>
    <div class="am-form-inline left-margin top-margin">
        <button type="submit" class="am-btn am-btn-primary" ng-click="showhNoticeCount(mode,type)">推送</button>
    </div>

    <div class="am-modal am-modal-no-btn" tabindex="-1" id="showPushNotice">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left;">推送
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <br>
            <div class="am-modal-bd body-area text-left">
                <form>
                    <div class="modal-body">
                        <p>
                        <ul>
                            <li>推送内容：{{messsage.sendMsg}}</li>
                            <br>
                            <li>预计发送人数：{{messsage.count}}</li>
                        </ul>

                        </p>
                    </div>
                </form>
            </div>
            <div class = "button-area border-top">
                <button type="button" data-am-modal="{target: '#loading'}" class="am-btn am-btn-success right-margin top-margin" ng-show="true" ng-click="pushMsg()">确认</button>
            </div>

        </div>
    </div>

    <!--loading-->
    <div class="am-modal am-modal-loading am-modal-no-btn" id="loading">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">正在推送...</div>
            <div class="am-modal-bd">
                <span class="am-icon-spinner am-icon-spin"></span>
            </div>
        </div>
    </div>

</div>

<script>

    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    var fromDate = $('#beginDate').datetimepicker().on('changeDate', function (ev) {

        $('#beginDate').datetimepicker({
            format: 'yyyy-mm-dd hh:ii'
        });

    });

    var toDate = $('#endDate').datetimepicker().on('changeDate', function (ev) {
        $('#endDate').datetimepicker({
            format: 'yyyy-mm-dd hh:ii'
        });
    });


</script>